<script src="/login/status"></script>
<script>
    if(!isLogin) location.href = "/admin/login.html"
</script>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理后台首页</title>
    <link rel="stylesheet" href="../assets/vendors/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../assets/css/common.css">
    <link rel="stylesheet" href="../assets/css/admin.css">
    <link rel="stylesheet" href="../assets/vendors/aliFont/iconfont.css">
    <link rel="stylesheet" href="../assets/vendors/nprogress/nprogress.css">
    <script src="../assets/vendors/nprogress/nprogress.js"></script>
    <script src="../assets/vendors/Jquery/jquery-1.11.0.min.js"></script>
</head>
<body>
    <script>NProgress.start()</script>
    <div class="indexBox clearfix">
           <div class="slide">
            <div class="slide-head">
                <div class="avatar">
                    <img src="../uploads/avatar.jpg" alt="">
                </div>
                <span class="user">Coder</span>
            </div>
            <div class="nav">
                <ul class="navItems">
                    <li class="navActive">
                        <a href="./index.html">
                             <span class=" iconfont icon-yibiaopan"></span>仪表盘
                        </a>
                    </li>
                    <li>
                        <div class="nav-item">
                            <a><span class=" iconfont icon-wenzhang"></span>文章<span class=" iconfont icon-arrow-right arrow"></span></a>
                        </div>
                        <ul class="itemgroup" >
                            <li><a href="articleAll.html">所有文章</a></li>
                            <li><a href="addArticle.html">写文章</a></li>
                            <li><a href="cateArticle.html">分类目录</a></li>
                        </ul>
                    </li>
                    <li><a href="./comments.html"><span class=" iconfont icon-chat"></span>评论</a></li>
                    <li><a href="./user.html"><span class=" iconfont icon-yonghu"></span>用户</a></li>
                    <li>
                        <div class="nav-item">
                           <a> <span class=" iconfont icon-shezhi"></span>设置<span class="iconfont icon-arrow-right arrow"></span></a>
                        </div>
                        <ul class="itemgroup" >
                            <li><a href="slides.html">图片轮播</a></li>
                            <li><a href="settings.html">网站设置</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <div class="main">
            <div class="content-head">
                <div class="content-icon">
                    <div class="content-left">
                        <span class="iconfont icon-shouqianniuicon"></span>
                    </div>
                </div>
                <div class="modify">
                    <a href="passwordReset.html">
                      <span class="iconfont icon-yonghu1"></span>修改密码
                    </a>
                </div>
                <div class="loginOut">
                    <span class="iconfont icon-tuichu_huaban1"></span><span>退出</span>
                </div>
            </div>
            <div class="content clearfix">
                <p>用户</p>
               <div class="row">
                    <div class="addUser col-md-4">
                            <span class="add-title">添加新用户</span>
                            <form action="" id="addUserForm">
                            <div class="formgroup">
                                <label for="">头像</label>
                                <div for="" class="formImg">
                                <input type="file" id="avatarInput" name="avatar">
                                    <img src="../assets/img/default.png" alt="" id="preview">
                                    <i class="iconfont icon-upload-fill"></i>
                                    <input type="hidden" id="inputHidden" name="avatar">
                                </div>
                            </div>
                            <div class="formgroup">
                                <label for="">邮箱</label>
                                <input type="text" placeholder="请输入邮箱" name="email" id="userEmail">
                            </div>
                            <div class="formgroup">
                            <label for="">昵称</label>
                                <input type="text" placeholder="请输入昵称" name="nickName">
                            </div>
                            <div class="formgroup">
                            <label for="">密码</label>
                                <input type="password" placeholder="请输入密码" name="password">
                            </div>
                            <div class="formgroup formCheckbox">
                                <input type="radio" name="status"value="0">
                                <label for="">未激活</label>
                                <input type="radio" name="status" value="1">
                                <label for="">激活</label>
                            </div> 
                             <div class="formgroup formCheckbox">
                                <input type="radio" name="role" value="admin">
                                <label for="">超级管理员</label>
                                <input type="radio" name="role" value="normal">
                                <label for="">普通用户</label>
                            </div>
                               <button type="submit" class="btn btn-primary btn-sm active">添加</button> 
                         </form>
                    </div>
                 
                    <div class="showUser col-md-8 visible-md-block visible-lg-block">
                        <div class="page-action" style="display: none">
                            <button type="button" class="btn btn-danger btn-sm active deleteMany">批量删除</button> 
                        </div>
                        <table class="table table-hover table-bordered table-striped userTable">
                            <thead>
                                <tr>
                                    <th width="5%"><input type="checkbox" class="selectAll"></th>
                                    <th width="10%">头像</th>
                                    <th width="25%">邮箱</th>
                                    <th width="15%">昵称</th>
                                    <th width="10%">状态</th>
                                    <th width="20%">角色</th>
                                    <th width="15%">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                              
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <script src="../assets/js/common.js"></script>
    
    <script src="../assets/vendors/art-template/template-web.js"></script>
    <script>NProgress.done()</script>
    <script type="text/html" id="userTpl">
        {{each data}}
        <tr>
            <td><input type="checkbox" name="" data-id="{{$value._id}}" class="select"></td>
            <td>
                {{if $value.avatar}}
                <img src="{{$value.avatar}}" alt=""></td>
                {{else}} 
                <img src="../assets/img/default.png" alt="" id="preview">
                {{/if}}
            <td>{{$value.email}}</td>
            <td>{{$value.nickName}}</td>
            <td>{{$value.status == "1"? "激活": "未激活"}}</td>
            <td>{{$value.role == "admin"? "超级管理员": "普通用户"}}</td>
            <td>                
                <button type="button" class="btn btn-default btn-xs" id="userModify" data-id="{{$value._id}}">编辑</button>
                <button type="button"  class="btn btn-danger btn-xs deleteUser" data-id="{{$value._id}}">删除</button>
            </td>
        </tr>
        {{/each}}
    </script>
    <script type="text/html" id="userModifyTpl">
        <span class="add-title">修改用户</span>
        <form action="" id="addUserForm" data-id="{{_id}}">
        <div class="formgroup">
            <label for="">头像</label>
            <div for="" class="formImg">
            <input type="file" id="avatarInput" name="avatar">
            {{if avatar}}
                <img src="{{avatar}}" alt="" id="preview">
            {{else}}
            <img src="../assets/img/default.png" alt="" id="preview">
            {{/if}}
                <i class="iconfont icon-upload-fill"></i>
                <input type="hidden" id="inputHidden" name="avatar">
            </div>
        </div>
        <div class="formgroup">
            <label for="">邮箱</label>
            <input type="text" placeholder="请输入邮箱" name="email" id="userEmail" value="{{email}}">
        </div>
        <div class="formgroup">
        <label for="">昵称</label>
            <input type="text" placeholder="请输入昵称" name="nickName" value="{{nickName}}">
        </div>
        <div class="formgroup formCheckbox">
            <input type="radio" name="status"value="0" {{status == 0?'checked': ''}}>
            <label for="">未激活</label>
            <input type="radio" name="status" value="1" {{status == 1?'checked': ''}}>
            <label for="">激活</label>
        </div> 
         <div class="formgroup formCheckbox">
            <input type="radio" name="role" value="admin" {{role == 'admin'?'checked': ''}}>
            <label for="">超级管理员</label>
            <input type="radio" name="role" value="normal" {{role == 'normal'?'checked': ''}}>
            <label for="">普通用户</label>
        </div>
           <button type="submit" class="btn btn-primary btn-sm active" id='userModifyBtn'>修改</button> 
     </form>
    </script>
    <script src="../assets/js/user.js"></script>
</body>
</html>